/**   
 * @Title: JobsDao.java 
 * @package com.sysmanage.permissions.dao 
 * @Description: 
 * @author XXXX@163.com 
 * @date 2011-9-20 下午1:25:44 
 * @version V1.0   
 */

package com.sysmanage.permissions.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sysmanage.common.tools.page.Pagination;
import com.sysmanage.framework.dao.hibernate.Finder;
import com.sysmanage.framework.dao.hspring.BaseDAO;
import com.sysmanage.framework.dao.hspring.handler.IHandler;
import com.sysmanage.permissions.model.Company;
import com.sysmanage.permissions.model.Jobs;
import com.sysmanage.permissions.model.Systems;

/** 
* @ClassName: JobsDao 
* @Description: 处理公司模块的DAO 
* @author XXXX@163.com 
* @date 2011-9-20 下午1:25:44 
*  
*/
@Repository(value="jobsDao")
public class JobsDao extends BaseDAO<Jobs> {
	/** 
	  * @Title: getPageList 
	  * @Description: 获取具体某页的信息
	  * @param @param sys 一条具体Systems对象的信息
	  * @param @param page 当前页
	  * @param @param rows 一页显示多少记录
	  * @param @return
	  * @return Pagination
	  * @throws 
	  */
	public Pagination getPageList(Jobs job,int page, int rows,String sort,String order) {
		StringBuffer sb = new StringBuffer("from Jobs where 1=1");
		if(null != job){
			if(null != job.getJobName() && !"".equals(job.getJobName())){
				sb.append(" and jobName like'%" + job.getJobName() + "%'");
			}
			if(null != job.getDeptId() && job.getDeptId()!=-1){
				sb.append(" and deptId =" + job.getDeptId());
			}
		}
		if(sort!=null && !"".equals(sort)){
			sb.append(" order by "+sort);
			if(order!=null && !"".equals(order)){
				sb.append(" "+order);
			}else{
				sb.append(" desc");
			}
		}
		return super.getHandler().getPageList(Finder.create(sb.toString()), page, rows);
	}
	
	/** 
	  * @Title: getAll 
	  * @Description: 获得所有资源记录集合
	  * @param @return
	  * @return List<Resources>
	  * @throws 
	  */
	public List<Jobs> getAll(){
		return this.findList("from Jobs");
	}
}
